#include <algorithm>
#include <bitset>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <istream>
#include <queue>
#include <utility>
#include <vector>
using ll = int64_t;

const ll maxn = 5000+7;
ll n,m,edge[maxn][2],del=-1,sum=0;
std::vector<std::priority_queue<ll,std::vector<ll>,std::greater<ll>>> e,ne;
std::bitset<maxn> b;
std::vector<ll>nans,ans;
#define printf
static inline void dfs(ll f,ll now){
    sum++;
    printf("dfs f=%lld, now=%lld, sum=%lld\n",f,now,sum);
    if(del==-1)std::cout<<now<<" ";
    if(del!=-1)nans[sum]=now;
    if(del!=-1 && sum==m){
        printf("GOT NEW ANS\n");
        if(nans<ans){
            std::swap(nans,ans);
        }
    }
    while(e[now].size()){
        ll top = e[now].top();
        e[now].pop();
        if(del!=-1 && ((edge[del][0]==now&&edge[del][1]==top)||(edge[del][1]==now&&edge[del][0]==top))){
            printf("continue now=%lld, top=%lld\n",now,top);
            continue;
        }
        printf("top=%lld\n",top);
        if(b[top])continue;
        b[top]=true;
        dfs(now,top);
    }
    printf("---dfs f=%lld, now=%lld\n",f,now);
}

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>n>>m;
    e.resize(n+1);
    nans.resize(n+1);
    ans.resize(n+1);
    b[1]=true;
    for(ll i=1;i<=m;i++){
        ll u,v;
        std::cin>>u>>v;
        edge[i][0]=u,edge[i][1]=v;
        e[u].push(v);
        e[v].push(u);
    }
    for(ll i=1;i<=m;i++)ans[i]=1e9+7;
    ne=e;
    if(m==n-1){
        dfs(0,1);
    }else{
        for(ll i=1;i<=m;i++){
            printf("BEGIN TREE i=%lld\n",i);
            e=ne;
            b.reset();
            b[1]=true;
            del=i;
            sum=0;
            dfs(0, 1);
        }
        for(int i=1;i<=n;i++){
            std::cout<<ans[i]<<" ";
        }
        std::cout<<"\n";
    }
    std::cout<<"\n";
}